#include "tipos.h"

// IO para Interno

ostream& operator<<(ostream& os, const Interno& output) {
  os << "< ";
  os << output.identificador;
  os << " ";
  os << output.trans;
  return os << " >";
}


istream& operator>>(istream& is, Interno& input) {
  char nextChar;
  is >> nextChar;
  assert(nextChar == '<');
  
  while(true) {
    is >> nextChar;
    if(nextChar == '>')
      break;
    is.putback(nextChar);
    IdInterno id;
    is >> id;
    is >> nextChar;
    is.putback(nextChar);
    string c;
    is >> c;
    if(c == "Automatico"){
           Interno i(0, id);
           input = i;
    }else{ 
           Interno i(1, id);
           input = i;
    }
  }

  return is;
}//ANDA OK!!!!!!!

// IO para Chofer

ostream& operator<<(ostream& os, const Chofer& output) {
  os << "< ";
  os << output.identificador;
  os << " ";
  os << output.age;
  return os << " >";
}//ANDA!!!

istream& operator>>(istream& is, Chofer& input) {
  char nextChar;
  is >> nextChar;
  assert(nextChar == '<');
  
  while(true) {
    is >> nextChar;
    if(nextChar == '>')
      break;
    is.putback(nextChar);
    IdChofer id;
    is >> id;
    is >> nextChar;
    is.putback(nextChar);
    int edad;
    is >> edad;
    Chofer c(edad, id);
    input = c;
  }

  return is;
}
//IO Para ConjInterno

ostream& operator<<(ostream& os, const ConjInterno& output){
  os << "{ ";
  iterConj<Interno> it;
  it.crearItc(output);
  while(it.tieneProximoc()){
       os << it.proximoc() << " ";
  }  
  return os << " }";       
 
}



istream& operator>>(istream& is, ConjInterno& input){
  char nextChar;
  is >> nextChar;
  assert(nextChar == '{');    
  while(true) {
    is >> nextChar;
    if(nextChar == '}')
      break;       
    is.putback(nextChar);
    Interno i;
    is >> i;
    input.ag(i);
  }

  return is;
}

// IO Para ConjChofer

ostream& operator<<(ostream& os, const ConjChofer& output){
  os << "{ ";
  iterConj<Chofer> it;
  it.crearItc(output);
  while(it.tieneProximoc()){
       os << it.proximoc() << " ";
  }  
  return os << " }";       
 
}



istream& operator>>(istream& is, ConjChofer& input){
  char nextChar;
  is >> nextChar;
  assert(nextChar == '{');    
  while(true) {
    is >> nextChar;
    if(nextChar == '}')
      break;       
    is.putback(nextChar);
    Chofer c;
    is >> c;
    input.ag(c);
  }

  return is;
}
